package com.sakura.oj.model.vo;

import com.sakura.oj.model.entity.JudgeConfig;
import com.sakura.oj.model.entity.Problem;
import com.sakura.oj.model.entity.ProblemJudgeCase;
import com.sakura.oj.model.entity.Tag;
import lombok.Data;
import org.springframework.beans.BeanUtils;

import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;

/**
 * 题目视图
 */
@Data
public class ProblemVO implements Serializable {

    /**
     * id
     */
    private Long id;

    /**
     * 标题
     */
    private String title;

    /**
     * 内容
     */
    private String content;

    /**
     * 提交数
     */
    private Integer submitNum;

    /**
     * 通过数
     */
    private Integer acceptedNum;

    /**
     * 难度；EASY简单，MEDIUM中等，HARD困难
     */
    private String difficulty;

    /**
     * 判题配置
     */
    private JudgeConfig judgeConfig;

    /**
     * 判题用例
     */
    private List<ProblemJudgeCase> judgeCaseList;

    /**
     * 标签列表
     */
    private List<Tag> tagsList;

    /**
     * 创建时间
     */
    private LocalDateTime createTime;

    /**
     * 更新时间
     */
    private LocalDateTime updateTime;

    /**
     * 包装类转对象
     *
     * @param postVO
     * @return
     */
    public static Problem voToObj(ProblemVO postVO) {
        if (postVO == null) {
            return null;
        }
        Problem problem = new Problem();
        BeanUtils.copyProperties(postVO, problem);

        return problem;
    }

    /**
     * 对象转包装类
     *
     * @param post
     * @return
     */
    public static ProblemVO objToVo(Problem post) {
        if (post == null) {
            return null;
        }
        ProblemVO problemVO = new ProblemVO();
        BeanUtils.copyProperties(post, problemVO);
        return problemVO;
    }

}
